<html>
<head><meta charset="utf-8"><title>Rendering the actual value of a `const` · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html">Rendering the actual value of a `const`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245567990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Rendering%20the%20actual%20value%20of%20a%20%60const%60/near/245567990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html#245567990">(Jul 10 2021 at 19:54)</a>:</h4>
<p>I think it would be useful to render the actual (computed) value of a <code>const</code> item in the documentation. For example, <code>pub const VAL: bool = my_const_fn()</code> would render the actual boolean returned by <code>my_const_fn()</code></p>



<a name="245568012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Rendering%20the%20actual%20value%20of%20a%20%60const%60/near/245568012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html#245568012">(Jul 10 2021 at 19:55)</a>:</h4>
<p>Obviously, this could start to get tricky with more complex types (e.g. <code>&amp;Foo&lt;Mutex&lt;String&gt;&gt;</code>), so we could start out by just rendering primitives</p>



<a name="245568090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Rendering%20the%20actual%20value%20of%20a%20%60const%60/near/245568090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html#245568090">(Jul 10 2021 at 19:57)</a>:</h4>
<p>My hidden agenda is to get better rendering of query providers in the rustc internal documentation. If we make all of the <code>provide</code> functions <code>const</code> (which I think it doable on nightly), we could construct <code>DEFAULT_QUERY_PROVIDERS</code> at compile-time. When we 'rendered' the value, we would render each function-pointer field with a link to the actual function implementation</p>



<a name="245568100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Rendering%20the%20actual%20value%20of%20a%20%60const%60/near/245568100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html#245568100">(Jul 10 2021 at 19:57)</a>:</h4>
<p>Which would allow compiler developers to go to the <code>DEFAULT_QUERY_PROVIDERS</code> page, and then jump to the actual definition of the query they're interested in</p>



<a name="245568622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Rendering%20the%20actual%20value%20of%20a%20%60const%60/near/245568622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html#245568622">(Jul 10 2021 at 20:10)</a>:</h4>
<p>Oh, it looks like we already do this <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="245569443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/Rendering%20the%20actual%20value%20of%20a%20%60const%60/near/245569443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/Rendering.20the.20actual.20value.20of.20a.20.60const.60.html#245569443">(Jul 10 2021 at 20:30)</a>:</h4>
<p>I openeed <a href="https://github.com/rust-lang/rust/issues/87038">https://github.com/rust-lang/rust/issues/87038</a> to track doing this for ADTs in addition to primitives</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>